package com.tianhua.javs.client.bean;

import com.tianhua.javs.client.enums.BusinessKeyWardEnum;
import com.tianhua.javs.client.model.AbstractClassModel;
import com.tianhua.javs.client.model.FieldModel;
import com.tianhua.javs.client.model.MethodModel;
import lombok.Data;

/**
 * Description:
 * date: 2022/2/10
 *
 * @author shenshuai
 * @version 1.0.0
 * @since JDK 1.8
 */
@Data
public class JavsParamBean {
    /**
     * 参数类型
     * Java 的变量类型
     */
    private String paramType;
    /**
     * 参数原始变量名
     * java的变量名
     */
    private String originParamName;

    /**
     * 在javs脚本中的变量名 有可能是dto,bo,do之类的业务关键字
     *
     * 或者bo.factory
     * bo.repository
     * bo.service
     * 有以下几种情况
     * bo.factory
     * bo.variableFactory
     * bo.conditionFunc
     * userBo.factory
     *
     * bo.memberId ---> 引用属性
     * bo.getInstance()
     *
     *
     */
    private String javsParamName;

    /**
     * javsParamName引用的类型或者代表的类型
     * 1.引用属性
     * 2.引用方法
     * 3.引用对象 springbean
     */
    private String javsParamReferType;





    /**
     * 参数范型
     */
    private String paramPattern;
    /**
     * 参数依赖包路径
     */
    private String packageName;


    /**
     * 是不是方法唯一参数
     *
     */
    private boolean isOnlyMethodParam;



    /**
     * 引用的对象
     */
    private AbstractClassModel referClass;

    /**
     * 引用的方法
     */
    private MethodModel referMethod;

    /**
     * 引用的属性
     */
    private FieldModel referField;


    public JavsParamBean(){}

    public JavsParamBean(String javsParamName){
        this.javsParamName = javsParamName;
    }

    public static JavsParamBean ofInstance(String javsParamName){
        return new JavsParamBean(javsParamName);
    }


    public boolean isStrictBO(){
        return this.javsParamName.equals(BusinessKeyWardEnum.BO.getKeyWardCode());
    }

    public boolean isGenerateBO(){
        return this.javsParamName.toLowerCase().endsWith(BusinessKeyWardEnum.BO.getKeyWardCode());
    }

    public boolean isStrictDTO(){
        return this.javsParamName.equals(BusinessKeyWardEnum.DTO.getKeyWardCode());
    }


    public boolean isGenerateDTO(){
        return this.javsParamName.toLowerCase().endsWith(BusinessKeyWardEnum.DTO.getKeyWardCode());
    }

    public boolean isStrictCMD(){
        return this.javsParamName.equals(BusinessKeyWardEnum.CMD.getKeyWardCode());
    }

    public boolean isGenerateCMD(){
        return this.javsParamName.toLowerCase().endsWith(BusinessKeyWardEnum.CMD.getKeyWardCode());
    }


    public boolean isStrictDO(){
        return this.javsParamName.equals(BusinessKeyWardEnum.DO.getKeyWardCode());
    }

    public boolean isGenerateDO(){
        return this.javsParamName.toLowerCase().endsWith(BusinessKeyWardEnum.DO.getKeyWardCode());
    }

    /*public boolean isDTO(){
        return false;
    }

    public boolean isDO(){

    }*/

}
